package org.boulderfoodrescue.webapp.client.events;

import org.boulderfoodrescue.webapp.shared.PickupReport;

import com.google.gwt.event.shared.GwtEvent;

public class PickupReportUpdatedEvent extends GwtEvent<PickupReportUpdatedHandler>{
	private static final Type<PickupReportUpdatedHandler> TYPE = new Type<PickupReportUpdatedHandler>();
	private ChangeType changeType;
	private PickupReport value;

	public PickupReportUpdatedEvent(ChangeType changeType, PickupReport value) {
		this.changeType = changeType;
		this.value = value;
	}

	public static Type<PickupReportUpdatedHandler> getType() {
		return TYPE;
	}

	@Override
	public com.google.gwt.event.shared.GwtEvent.Type<PickupReportUpdatedHandler> getAssociatedType() {
		return TYPE;
	}

	@Override
	protected void dispatch(PickupReportUpdatedHandler handler) {
		switch(changeType)
		{
		case Added: handler.onPickupReportAdded(this);break;
		case Removed: handler.onPickupReportRemoved(this);break;
		case Updated: handler.onPickupReportUpdated(this);break;
		}
	}

	public PickupReport getValue(){
		return value;
	}
}
